<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<!--模板-->
<template id="tp1">
  <div>
    <h1>标题2</h1>
    <button v-for="cat in ccatgories" @click="btnclick(cat)" value="sexy">{{cat}}</button>
    <ul v-for="item in cmoives">
      <li>{{item}}</li>
    </ul>
    {{cmessage}}
    <h1>结尾2</h1>
  </div>
</template>


<!--显示主体-->
<div id="app">
<!--  父亲传儿子-->
<!--  ：-》父传子  @-》 子传父 -->
  <eda :cmoives="movies" :cmessage="message"  :ccatgories="catgories" @son2father="eventhandle"></eda>
  <h1>用户选择为{{userchoice}}</h1>
</div>




<script src="../js/vue.js"></script>
<script>

<!--   son-->
  const eda={

    template:'#tp1',
    data(){return {}  },
    props: {
     cmessage:{
       type:String,
       default:'radins middle tower is under attack',
        required:true,
     },
      cmoives:{
       type:Array,
        default(){
         return []
        }
        },
        ccatgories: {
          type: Array,
          default() {
            return []
          }
        }



    },
    methods:{
      btnclick(item){
        this.$emit('son2father',item)
      }
    }
  }


<!--  father-->
  const app = new Vue({
    el:"#app",
    data: {
      message:"stupid mother fucker",
      movies:['onepiece','naurto','overlord'],
      catgories:['数码','家电','情趣'],
      userchoice:'热门',
    },
    components:{
      eda
    },
    methods:{
      eventhandle(cat){
        this.userchoice=cat;
      }
    }


  })



</script>

</body>
</html>